function f = xFeatures(x, num_tilings, num_tiles, tile_width)

    %f = zeros(1, 1*num_tiles + (num_tilings-1)*(num_tiles+1));
    f = zeros(1, num_tilings);
    
    if(x == 0) 
        init_pos = 1;
    else
        init_pos = ceil(x/tile_width); % for the base tiling
    end
    
    %f(init_pos) = 1;
    f(1) = init_pos;
    
    for i=2:num_tilings,
        old_tilings = 1*num_tiles + (i-2)*(num_tiles+1); % number of tiles in the previous tilings
        
        offset = ((i-1)/num_tilings)*tile_width; % offset from the first tile
        
        if(x <= offset)
            pos = old_tilings + 1;
        else 
            pos = old_tilings + 1 + ceil((x-offset)/tile_width);
        end

        %f(pos) = 1;
        f(i) = pos;
    end

end